import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { InterviewService } from './interview.service';
import { CreateInterviewDto } from './dto/create-interview.dto';
import { CategoryDto } from './dto/category.dto';

@Controller('micro-app/v1')
export class InterviewController {
  constructor(private readonly interviewService: InterviewService) {}

  // 删除文章
  @Post('postDelArticle')
  postDelArticle(@Body() interviewDto: CreateInterviewDto) {
    return this.interviewService.postDelArticle(interviewDto);
  }

  // 查询文章
  @Post('postQueryArticle')
  postQueryArticle(@Body() interviewDto: CreateInterviewDto) {
    return this.interviewService.postQueryArticle(interviewDto);
  }

  // 查询分类
  @Post('postQueryCategory')
  postQueryCategory(@Body() body: CategoryDto) {
    return this.interviewService.postQueryCategory(body);
  }

  // 创建分类
  @Post('postCreateCategory')
  postCreateCategory(@Body() body: CategoryDto) {
    return this.interviewService.postCreateCategory(body);
  }

  // 保存文章
  @Post('postSaveArticle')
  postSaveArticle(@Body() body: CreateInterviewDto) {
    return this.interviewService.postSaveArticle(body);
  }

  @Post()
  create(@Body() body) {
    return this.interviewService.create(body);
  }

  @Get()
  findAll() {
    return this.interviewService.findAll();
  }

  @Get(':uid')
  findOne(@Param('uid') id: string) {
    return this.interviewService.findOne(id);
  }

  @Patch(':id')
  update(@Body() body: CreateInterviewDto) {
    return this.interviewService.update(body);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.interviewService.remove(+id);
  }
}
